import 'dart:async';

import 'package:flutter/material.dart';

class AnimatedCrossFadeDemo extends StatefulWidget {
  AnimatedCrossFadeDemo({Key key}) : super(key: key);

  @override
  _AnimatedCrossFadeDemoState createState() => _AnimatedCrossFadeDemoState();
}

class _AnimatedCrossFadeDemoState extends State<AnimatedCrossFadeDemo> {
  var _first = false;

  @override
  Widget build(BuildContext context) {
    new Timer(new Duration(seconds: 3), () {
      setState(() {
        _first = !_first;
      });
    });
    return Scaffold(
      appBar: AppBar(
        title: Text('AnimatedCrossFadeDemo'),
      ),
      body: AnimatedCrossFade(
        duration: const Duration(seconds: 3),
        firstChild:
            const FlutterLogo(style: FlutterLogoStyle.horizontal, size: 100.0),
        secondChild:
            const FlutterLogo(style: FlutterLogoStyle.stacked, size: 100.0),
        crossFadeState:
            _first ? CrossFadeState.showFirst : CrossFadeState.showSecond,
      ),
    );
  }
}
